import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '问卷标题',
    align:"center",
    sorter: true,
    dataIndex: 'title'
   },
   {
    title: '是否启用',
    align:"center",
    sorter: true,
    dataIndex: 'status_dictText'
   },
   {
    title: '问卷说明',
    align:"center",
    dataIndex: 'description'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "问卷标题",
      field: "title",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "是否启用",
      field: "status",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"wx_question_check"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '问卷标题',
    field: 'title',
    component: 'Input',
  },
  {
    label: '是否启用',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"wx_question_check"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否启用!'},
          ];
     },
  },
  {
    label: '问卷说明',
    field: 'description',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const questionItemColumns: JVxeColumn[] = [
    {
      title: '题目内容',
      key: 'question',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '题型',
      key: 'questionType',
      type: JVxeTypes.select,
      options:[],
      dictCode:"wx_question_type",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '选项(JSON数组)，仅限radio/checkbox',
      key: 'options',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '排序值',
      key: 'sortOrder',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '是否必填',
      key: 'required',
      type: JVxeTypes.select,
      options:[],
      dictCode:"wx_question_check",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  title: {title: '问卷标题',order: 0,view: 'text', type: 'string',},
  status: {title: '是否启用',order: 1,view: 'list', type: 'string',dictCode: 'wx_question_check',},
  description: {title: '问卷说明',order: 2,view: 'textarea', type: 'string',},
  //子表高级查询
  questionItem: {
    title: '问卷题目表',
    view: 'table',
    fields: {
        question: {title: '题目内容',order: 0,view: 'textarea', type: 'string',},
        questionType: {title: '题型',order: 1,view: 'list', type: 'string',dictCode: 'wx_question_type',},
        options: {title: '选项(JSON数组)，仅限radio/checkbox',order: 2,view: 'textarea', type: 'string',},
        sortOrder: {title: '排序值',order: 3,view: 'number', type: 'number',},
        required: {title: '是否必填',order: 4,view: 'number', type: 'number',dictCode: 'wx_question_check',},
    }
  },
};
